/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Lob;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "activesubstance")
@XmlRootElement
@NamedQueries({
	@NamedQuery(name = "Activesubstance.maxSubstanceActiveId", query = "SELECT max(a.activeSubstanceId) FROM Activesubstance a"),
    @NamedQuery(name = "Activesubstance.findAll", query = "SELECT a FROM Activesubstance a"),
    @NamedQuery(name = "Activesubstance.findByActiveSubstanceId", query = "SELECT a FROM Activesubstance a WHERE a.activeSubstanceId = :activeSubstanceId"),
    @NamedQuery(name = "Activesubstance.findByName", query = "SELECT a FROM Activesubstance a WHERE a.name = :name"),
    @NamedQuery(name = "Activesubstance.findBySynonyms", query = "SELECT a FROM Activesubstance a WHERE a.synonyms = :synonyms"),
    @NamedQuery(name = "Activesubstance.findByTherapeuticAction", query = "SELECT a FROM Activesubstance a WHERE a.therapeuticAction = :therapeuticAction")})
public class Activesubstance implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "activeSubstanceId")
    private Integer activeSubstanceId;
    @Basic(optional = false)
    @Column(name = "name")
    private String name;
    @Column(name = "synonyms")
    private String synonyms;
    @Basic(optional = false)
    @Column(name = "therapeuticAction")
    private String therapeuticAction;
    @Basic(optional = false)
    @Lob
    @Column(name = "properties")
    private String properties;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "activesubstance")
    private Collection<Attribute> attributeCollection;
    @OneToMany(mappedBy = "activeSubstanceId")
    private Collection<Product> productCollection;

    public Activesubstance() {
    }

    public Activesubstance(Integer activeSubstanceId) {
        this.activeSubstanceId = activeSubstanceId;
    }

    public Activesubstance(Integer activeSubstanceId, String synonyms, String name, String therapeuticAction, String properties) {
        this.activeSubstanceId = activeSubstanceId;
        this.name = name;
        this.synonyms = synonyms;
        this.therapeuticAction = therapeuticAction;
        this.properties = properties;
    }

    public Integer getActiveSubstanceId() {
        return activeSubstanceId;
    }

    public void setActiveSubstanceId(Integer activeSubstanceId) {
        this.activeSubstanceId = activeSubstanceId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSynonyms() {
        return synonyms;
    }

    public void setSynonyms(String synonyms) {
        this.synonyms = synonyms;
    }

    public String getTherapeuticAction() {
        return therapeuticAction;
    }

    public void setTherapeuticAction(String therapeuticAction) {
        this.therapeuticAction = therapeuticAction;
    }

    public String getProperties() {
        return properties;
    }

    public void setProperties(String properties) {
        this.properties = properties;
    }

    @XmlTransient
    public Collection<Attribute> getAttributeCollection() {
        return attributeCollection;
    }

    public void setAttributeCollection(Collection<Attribute> attributeCollection) {
        this.attributeCollection = attributeCollection;
    }

    @XmlTransient
    public Collection<Product> getProductCollection() {
        return productCollection;
    }

    public void setProductCollection(Collection<Product> productCollection) {
        this.productCollection = productCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (activeSubstanceId != null ? activeSubstanceId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Activesubstance)) {
            return false;
        }
        Activesubstance other = (Activesubstance) object;
        if ((this.activeSubstanceId == null && other.activeSubstanceId != null) || (this.activeSubstanceId != null && !this.activeSubstanceId.equals(other.activeSubstanceId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Activesubstance[ activeSubstanceId=" + activeSubstanceId + " ]";
    }
    
}
